package app.util.image.action
{
	import app.gui.control.*;
	import app.util.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.utils.*;
	
	public class AbstractAction
	{
		public virtual function getDescription():String
		{
			return "";
		}

		public virtual function getActionedBitmapData():BitmapData
		{
			throw new Error("Invalid action");
		}
		
		public function applyImage():void
		{
			try
			{
				var data:BitmapData = this.getActionedBitmapData();
				if(data != null)
				{
					var desc:String = this.getDescription();
					Mediator.getCurrentImageConfig().pushState(data, desc);
				}
				Mediator.getLogger().log("Image effect applied");
				//For time-consuming, they will call pushState afterwards
			}
			catch(e:Error)
			{
				Mediator.handleImageProcessingError(e);
			}
		}
	}
}